package nancal.mp.db.mongo.entity

import nancal.mp.db.mongo.base.shop.DiscussItem
import nbcp.base.db.IdName
import nbcp.base.db.IdNameUrl
import nbcp.base.db.IdUrl
import nbcp.base.db.annotation.DbEntityGroup
import nbcp.base.model.BaseMarkEntity
import org.springframework.data.mongodb.core.mapping.Document


/**
 * 文章组
 */
@Document
@DbEntityGroup("cms")
data class ArticleGroup(
    var code: String = "",
    var name: String = "",
    /**
     * 从根节点到父节点Id的路径，中间用 . 连接
     */
    var pwbs: String = "",
    var order: Float = 0F,
    var corp: IdName = IdName()
) : BaseMarkEntity()

/**
 * 文件组下的文章
 */
@Document
@DbEntityGroup("cms")
open class Article : BaseMarkEntity() {
    var groups: MutableList<IdName> = mutableListOf()   //文章属于多个组
    var name: String = ""    //标题
    var author: String = ""
    var logo: IdUrl = IdUrl() // 封面图

    var tags: MutableSet<String> = mutableSetOf()
    var body: String = ""
    var corp: IdName = IdName()
    var order: Float = 0F

    var code: String = ""       //特殊标记
    var link: String = ""       //外部链接

    var linkArticles: MutableList<IdName> = mutableListOf()     //链接的其它文章
    var linkProducts: MutableList<IdNameUrl> = mutableListOf()  //链接的商品
    var discussions: MutableList<DiscussItem> = mutableListOf()  //评论
}


@Document
@DbEntityGroup("cms")
data class ArticleFavorite(
    var article: IdName = IdName(), //文章
    var user: IdName = IdName()
) : BaseMarkEntity()